//
//  AY_BookSortPage.m
//  AiYue
//
//  Created by boWen on 2023/10/25.
//

#import "AY_BookSortPage.h"
#import "ZJScrollPageView.h"
#import "AY_BookSubSortPage.h"
@interface AY_BookSortPage ()<ZJScrollPageViewDelegate>
@property (strong, nonatomic) NSArray<NSString *> *titles;
@property (strong, nonatomic) NSArray<UIViewController *> *childVcs;
@property (nonatomic, strong) ZJScrollPageView *scrollPageView;

@end

@implementation AY_BookSortPage

- (void)viewDidLoad {
    [super viewDidLoad];
    self.gk_navigationBar.hidden = YES;
    [self setInitScrollerPageView];
}



- (void)setInitScrollerPageView {
    ZJSegmentStyle *style = [[ZJSegmentStyle alloc] init];
    style.gradualChangeTitleColor = YES;
    style.showLine = YES;
    style.selectedTitleColor = COLOR(@"#000002");
    style.normalTitleColor = COLOR(@"#878592");
    style.scrollLineColor = THEME_COLOR;
    style.scrollLineHeight = YNUM(3);
    style.scaleTitle = YES;
    style.titleMargin = 30;
    style.adjustCoverOrLineWidth = YES;
    style.titleFont = [UIFont systemFontOfSize:YNUM(15) weight:UIFontWeightMedium];
    _scrollPageView = [[ZJScrollPageView alloc] initWithFrame:CGRectMake(0, GK_STATUSBAR_HEIGHT, self.view.bounds.size.width , self.view.bounds.size.height - GK_STATUSBAR_HEIGHT) segmentStyle:style titles:self.titles parentViewController:self delegate:self];
    [self.view addSubview:_scrollPageView];
}

- (NSArray<NSString *> *)titles {
    if(!_titles) {
        _titles = @[@"分类"];
    }
    return _titles;
}

#pragma ZJScrollPageViewDelegate 代理方法
- (NSInteger)numberOfChildViewControllers {
    return self.titles.count;
}

- (UIViewController<ZJScrollPageViewChildVcDelegate> *)childViewController:(UIViewController<ZJScrollPageViewChildVcDelegate> *)reuseViewController forIndex:(NSInteger)index {
    AY_BookSubSortPage<ZJScrollPageViewChildVcDelegate> *childVc = (AY_BookSubSortPage*)reuseViewController;
    if (childVc == nil) {
        childVc = [[AY_BookSubSortPage alloc] init];
    }
    childVc.indx = index;
    return childVc;
}


- (BOOL)shouldAutomaticallyForwardAppearanceMethods {
    return NO;
}

@end
